﻿<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/MasterPage.master" CodeFile="ShareMonthFormProject.aspx.vb" Inherits="ShareMonthFormProject" %>

<%@ Register Assembly="ISNet.WebUI.WebTreeView" Namespace="ISNet.WebUI.WebTreeView" TagPrefix="ISWebTreeView" %>

<%@ Register Assembly="ISNet.WebUI.WebGrid" Namespace="ISNet.WebUI.WebGrid" TagPrefix="ISWebGrid" %>

<%@ Register Assembly="ISNet.WebUI.WebCombo" Namespace="ISNet.WebUI.WebCombo" TagPrefix="ISWebCombo" %>

<%@ Register Assembly="ISNet.WebUI.WebDesktop" Namespace="ISNet.WebUI.WebDesktop" TagPrefix="ISWebDesktop" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <link href="js/magicsuggest-1.2.6.css" rel="stylesheet" />
    <script src="js/magicsuggest-1.2.6.js"></script>
    <script src="script/packed.js"></script>
    <script src="script/tinybox.js"></script>
    <link href="script/style.css" rel="stylesheet" />
    <script type="text/javascript" src="js/JSON.js"></script>
    <script type="text/javascript">
        function openJS() { alert('loaded') }
        function closeJS() { doupdate() }
        function closeJS2() { doupdate() }
        function doupdate() {
            var grid = ISGetObject("WebGrid1");
            grid.ClearSelectedObject();
            grid.RootTable.UpdateUI();
            grid.RefreshAll();

        }
        function popupattach1() {

            var grid = ISGetObject("WebGrid1");
            var row = grid.GetSelectedObject().GetRowObject();



            //get the key value of selected row.
            var key = row.KeyValue;

            TINY.box.show({ iframe: 'neatupload.aspx?BDID=' + key, boxid: 'frameless', width: 540, height: 450, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { closeJS() } });




        }
        function popupkrajay3(keys) {


            TINY.box.show({ iframe: 'krajaymonths.aspx?BDID=' + keys, boxid: 'frameless', width: 350, height: 170, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { closeJS() } });




        }
        function popupattach2() {

            var grid = ISGetObject("WebGrid1");
            var row = grid.GetSelectedObject().GetRowObject();
            var key = row.KeyValue;

            //get the key value of selected row.
            TINY.box.show({ iframe: 'AttachmentListPopup.aspx?BDID=' + key, boxid: 'frameless', width: 350, height: 250, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { closeJS2() } })
        }
    </script>

    <script>
        function WebGrid1_OnAfterExitEditMode(controlId, tblName, editObject) {

            var WebGrid1 = ISGetObject(controlId);
            var rootTable = WebGrid1.RootTable;
            var cell = wgGetCellByElement(editObject.cellElement);
            var colName = cell.Name;

            var row = cell.Row;
            var htmlRow = row.GetElement();

            var cellsplit = cell.Value.toString().split(".");

            if (cellsplit[1] !== undefined && cellsplit[1].length > 2) {
                cell.SetText(cell.Text, true);
            }

            if (colName != "Project" && colName != "cmmts" && colName != "products" && colName != "acttype" && colName != "cmmtdet" && colName != "acti") {
                var cellval = 0;
                cellval = cell.Value;
                if (cellval + '' == "NaN" || cellval == 0) {
                    cell.SetText("0.00", true);
                }
            }


        }
        function Test() {
            var grid = ISGetObject("WebGrid1");
            var checkbox = grid.GetSelectedObject().GetRowObject().GetCells().GetNamedItem("Checker");

        }
        function WebGrid1_OnRowContextMenu(controlId, rowType, rowElement, menuObject) {
            menuObject.Items[0].Hide();

            return false;
        }
        function FundCenterCombo_OnAfterItemSelected(controlId) {


            var grid = ISGetObject("WebGrid1");
            var row = grid.GetSelectedObject().GetRowObject();



            var code_combo = ISGetObject("ProjectCombo");
            code_combo.ClearSelection();
            code_combo.Value = "";
            code_combo.SetTextBoxValue("");
            row.GetCells().GetNamedItem("Project").SetText("", true);



        }

        function OnRowSelect(controlId, tblName, rowIndex, rowElm) {


            var grid = ISGetObject("WebGrid1");
            var ar = grid.GetSelectedObject().GetRowElement();
            if (ar.IsAddNewRow == false) {

                var row = grid.GetSelectedObject().GetRowObject();


                var combo = ISGetObject("FundCenterCombo");
                var Val = row.GetCells().GetNamedItem("FundCenter").Value

                combo.SetValue(Val);
            }

        }
        function WebGrid1_OnRowValidate(rowObject) {
            return true;
            // retrieves WebGrid's object
            var grid = ISGetObject("WebGrid1");

            // access WebGrid's RootTable
            var rootTable = grid.RootTable;

            var row = rootTable.ToRowObject(rowObject); // convert the rowObject (HTMLElement) to WebGridRow object
            var htmlRow = row.GetElement();
            var cells = row.GetCells(); // get collection of WebGridCell
            var error = 0;
            var err_text = "กรุณาตรวจสอบ \n"

            //alert("1");
            var data


            data = wgGetCellByPosition(htmlRow, 9).innerText;
            var num2 = parseFloat((wgGetCellByPosition(htmlRow, 9).innerText).replace(/\,/g, ''));
            if (num2 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนมกราคม";
                error = error + 1;
            }

            data = wgGetCellByPosition(htmlRow, 10).innerText;
            var num3 = parseFloat((wgGetCellByPosition(htmlRow, 10).innerText).replace(/\,/g, ''));
            if (num3 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ●  ยอดกระจายเดือนกุมภาพันธ์";
                error = error + 1;
            }



            data = wgGetCellByPosition(htmlRow, 11).innerText;
            var num4 = parseFloat((wgGetCellByPosition(htmlRow, 11).innerText).replace(/\,/g, ''));
            if (num4 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนมีนาคม";
                error = error + 1;
            }


            data = wgGetCellByPosition(htmlRow, 12).innerText;
            var num5 = parseFloat((wgGetCellByPosition(htmlRow, 12).innerText).replace(/\,/g, ''));
            if (num5 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนเมษายน";
                error = error + 1;
            }

            data = wgGetCellByPosition(htmlRow, 13).innerText;
            var num6 = parseFloat((wgGetCellByPosition(htmlRow, 13).innerText).replace(/\,/g, ''));
            if (num6 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนพฤษภาคม";
                error = error + 1;
            }

            data = wgGetCellByPosition(htmlRow, 14).innerText;
            var num7 = parseFloat((wgGetCellByPosition(htmlRow, 14).innerText).replace(/\,/g, ''));
            if (num7 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนมิถุนายน";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 15).innerText;
            var num8 = parseFloat((wgGetCellByPosition(htmlRow, 15).innerText).replace(/\,/g, ''));
            if (num8 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนกรกฏาคม";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 16).innerText;
            var num9 = parseFloat((wgGetCellByPosition(htmlRow, 16).innerText).replace(/\,/g, ''));
            if (num9 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนสิงหาคม";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 17).innerText;
            var num10 = parseFloat((wgGetCellByPosition(htmlRow, 17).innerText).replace(/\,/g, ''));
            if (num10 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนกันยายน";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 18).innerText;
            var num11 = parseFloat((wgGetCellByPosition(htmlRow, 18).innerText).replace(/\,/g, ''));
            if (num11 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนตุลาคม";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 19).innerText;
            var num12 = parseFloat((wgGetCellByPosition(htmlRow, 19).innerText).replace(/\,/g, ''));
            if (num12 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนพฤศจิกายน";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 20).innerText;
            var num13 = parseFloat((wgGetCellByPosition(htmlRow, 20).innerText).replace(/\,/g, ''));
            if (num13 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายเดือนธันวาคม";
                error = error + 1;
            }

            data = wgGetCellByPosition(htmlRow, 21).innerText;
            var num14 = parseFloat((wgGetCellByPosition(htmlRow, 21).innerText).replace(/\,/g, ''));
            if (num14 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายปี " + "<%= Val(PlanYearsTxt.Text) +1 %>";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 22).innerText;
            var num15 = parseFloat((wgGetCellByPosition(htmlRow, 22).innerText).replace(/\,/g, ''));
            if (num15 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายปี " + "<%= Val(PlanYearsTxt.Text) + 2%>";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 23).innerText;
            var num16 = parseFloat((wgGetCellByPosition(htmlRow, 23).innerText).replace(/\,/g, ''));
            if (num16 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายปี " + "<%= Val(PlanYearsTxt.Text) + 3%>";
                error = error + 1;
            }
            data = wgGetCellByPosition(htmlRow, 24).innerText;
            var num17 = parseFloat((wgGetCellByPosition(htmlRow, 24).innerText).replace(/\,/g, ''));
            if (num17 <= 0 || data.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ') == "") {
                err_text = err_text + "\n   ● ยอดกระจายปี " + "<%= Val(PlanYearsTxt.Text) + 4%>";
                error = error + 1;
            }
            //alert("2");
            if (error == 0) {

                return true;
            } else {
                alert(err_text);
                return false;
            }

        }

        function WebGrid1_OnEditKeyDown(controlId) {
            //alert(event.keyCode);
            var grid = ISGetObject("WebGrid1");

            var totalRows = grid.TotalRows;
            var totalCells = grid.TotalCells;
            var curRow = grid.GetSelectedObject().rowIndex;
            var curCell = grid.GetActiveEditCell().cellIndex;

            // if enter key
            if (event.keyCode == 13) {
                if (totalRows >= 2) {
                    if (curRow < totalRows - 1) {
                        keyDown(curRow, curRow + 1, curCell - 1);
                    }
                }
                //grid.ExitEdit(1,0,0);
                //return false;
                //var ar = grid.GetSelectedObject().GetRowElement();

                //if (ar.IsAddNewRow) {
                //    ar.commit();
                //}
                //else {
                //    event.keyCode = 40;
                //    keyDown(curRow, curRow + 1, curCell - 1);
                //}
            }

                // if up arrow
            else if (event.keyCode == 38 && grid.GetSelectedObject().GetRowObject().Type != "NewRow") {
                if (totalRows >= 2) {
                    if (curRow > 0) {
                        keyDown(curRow, curRow - 1, curCell - 1);
                    }
                }
            }

                // if down arrow key
            else if (event.keyCode == 40 && grid.GetSelectedObject().GetRowObject().Type != "NewRow") {
                if (totalRows >= 2) {
                    if (curRow < totalRows - 1) {
                        keyDown(curRow, curRow + 1, curCell - 1);
                    }
                }
            }
                // if left arrow key
            else if (event.keyCode == 37) {
                if (curCell > 0) {
                    //jq(document).trigger(jq.Event('keydown', { keyCode: 9, shiftKey: true }));
                    //var press = jQuery.Event("keydown");
                    //press.shiftKey = false;
                    //press.which = 9;
                    //jq("WebGrid1").trigger(press);
                    //alert("x");
                    //return;
                    keyDown2(curRow, curRow, curCell - 2);

                }
            }
                // if right arrow key
            else if (event.keyCode == 39) {
                //if (curCell < totalCells - 1) {
                event.keyCode = 9;
                //}
            }


        }

        function keyDown(curRow, nextRow, cell) {
            var grid = ISGetObject("WebGrid1");
            var nextRowEl = grid.RootTable.GetRow(nextRow);
            var curRowEl = grid.RootTable.GetRow(curRow);
            var cell1 = nextRowEl.GetCell(cell);
            var cell2 = curRowEl.GetCell(cell);
            grid.SetFocus();
            cell2.Select(true);
            nextRowEl.Select();
            cell1.ActivateEdit();
        }
        function keyDown2(curRow, nextRow, cell) {
            var grid = ISGetObject("WebGrid1");
            var nextRowEl = grid.RootTable.GetRow(nextRow);
            var curRowEl = grid.RootTable.GetRow(curRow);
            var cell1 = nextRowEl.GetCell(cell);
            var cell2 = curRowEl.GetCell(cell);
            grid.SetFocus();
            cell1.Select(true);
            nextRowEl.Select();
            cell1.ActivateEdit();

        }

        function triggerKeyEvents(field, keyCode, shiftKey, ctrlKey) {

            field = $(field);

            shiftKey = Boolean(shiftKey);

            ctrlKey = Boolean(ctrlKey);


            field.simulate("keydown", {
                keyCode: keyCode,

                ctrlKey: ctrlKey,

                shiftKey: shiftKey
            });

            field.simulate("keypress", {
                keyCode: keyCode,

                ctrlKey: ctrlKey,

                shiftKey: shiftKey
            });


            if (field.is(HTML5_TEXT_INPUT_FIELD_SELECTOR)) {

                applyKeyCodeToValue(field, keyCode);

            }


            field.simulate("keyup", {
                keyCode: keyCode,

                ctrlKey: ctrlKey,

                shiftKey: shiftKey
            });

        }

        function SaveScrollPosition(gridId, action) {
            // collecting the last position
            // of the vertical scrollbar
            // by obtaining the scrollTop property
            var grid = ISGetObject(gridId);
            // obtain the scrollTop and scrollLeft property 
            // of the vertical scrollbar and horizontal scrollbar
            var vl = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollTop + "";
            var hl = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollLeft + "";
            // only send the scrollTop property
            // of the server if the action performed
            // by the grid OTFPB is 'Refresh'

            //if (action == "Refresh") {
            // sending over the scrollTop and scrollLeft property
            // to the server by using AddInput method
            grid.AddInput("scrollTopPos", vl);
            grid.AddInput("scrollLeftPos", hl);
            //}

            return true;
        }

        function ApplyLatestScroll(gridId, y, x) {
            // set back the previous scrollTop and scrollLeft property or
            // vertical and horizontal scroll position with 
            // the parameter sent from the server side
            var grid = ISGetObject(gridId);
            // manually configure the vertical and horizontal scroll position
            grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollTop = y;
            grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollLeft = x;

            var cellEl = grid.GetActiveEditCell().ToCellObject();
            grid.SetFocus();
            cellEl.ActivateEdit();
            return true;
        }

        function CustomRequestDel() {
            if (confirm('กรุณายืนยันการลบข้อมูล') == false) {
                return false
            }
            var grid = ISGetObject("WebGrid1");
            var table = grid.GetRootTable();
            var checkedRows = table.GetCheckedRows();

            if (checkedRows.length == 0) {
                alert("Please check an item.");
                setTimeout(function () { grid.SetFocus(); }, 10);
            }
            else {

                grid.AddInput("type", "2");
                grid.SendCustomRequest();

            }

            event.cancelBubble = true;
            event.returnValue = false;
        }

        function CustomRequestCopy() {
            if (confirm('กรุณายืนยันการคัดลอกข้อมูล') == false) {
                return false
            }
            var grid = ISGetObject("WebGrid1");
            var table = grid.GetRootTable();
            var checkedRows = table.GetCheckedRows();

            if (checkedRows.length == 0) {
                alert("Please check an item.");
                setTimeout(function () { grid.SetFocus(); }, 10);
            }
            else {

                grid.AddInput("type", "1");
                grid.SendCustomRequest();

            }

            event.cancelBubble = true;
            event.returnValue = false;
        }
        // This function is invoked when the custom request is about to be made.
        function wgPrepareCustomAction(grid, xmlr, name) {
            grid.SetStatus1("Processing...");
            return true;
        }
        var exp = '0';
        function WebTreeView3_Expand() {
            exp = '1';
            var combo = ISGetObject("WebCombo3");
            combo.SetFocus();
            combo.ShowDropDown();
        }
        function WebTreeView3_Collapse() {
            exp = '1';
            var combo = ISGetObject("WebCombo3");
            combo.SetFocus();
            combo.ShowDropDown();
        }
        function WebCombo3_Hide() {
            if (exp == '1') {
                exp = '0';
                var combo = ISGetObject("WebCombo3");
                combo.SetFocus();
                combo.ShowDropDown();
            }
        }

        function WebGrid1_OnEnterEditMode(controlId, tblName, editObject) {

        }

        function popupwaitForce() {
            TINY.box.show({ iframe: 'loading.html', boxid: 'frameless', close: 0, width: 300, height: 260, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { } });
            return false;
        }

    </script>
    <style>
        .WC4-DD-N {
            height: 0px;
        }

        .WC4-DD-A {
            height: 0px;
        }
    </style>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div style="margin-left: 10px; padding: 10px 10px 10px 10px;">
        <div style="float: left; width: 97%; border: solid; border-color: gray; border-width: 1px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; text-align: right; padding: 5px 5px 5px 5px;">
            <div style="text-align: right; margin-top: 5px;">
                <div align="left" style="width: 600px; float: left">
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </div>

                ปี&nbsp;
            <asp:TextBox ID="PlanYearsTxt" runat="server" Width="50px" Enabled="false" Style="text-align: center;"></asp:TextBox>
                &nbsp;&nbsp;&nbsp;&nbsp;
            Version&nbsp;
            <asp:TextBox ID="VersionTxt" runat="server" Width="30px" Enabled="false" Style="text-align: center"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="#" title="เลือกหน่วยงานและโครงการที่ต้องการ จากนั้นคลิกที่ปุ่มนี้เพื่อทำการค้นหา">
                <asp:ImageButton ID="SearhBtn" runat="server" ImageUrl="Icons/search.jpg" OnClientClick="clickedx()" /></a>
                <%--  &nbsp;&nbsp;<a href="#" title="เลือกรายการที่ต้องการ จากนั้นคลิกปุ่มนี้เพิ่อทำการคัดลอกรายการ"><asp:ImageButton ID="coppy_btn" runat="server" ImageUrl="Icons/copy.jpg" OnClientClick="CustomRequestCopy(); return false" /></a>
                &nbsp;&nbsp;<a href="#" title="เลือกรายการที่ต้องการ จากนั้นคลิกปุ่มนี้เพิ่อทำการลบรายการ"><asp:ImageButton ID="delete_btn" runat="server" ImageUrl="Icons/delete.jpg" OnClientClick="CustomRequestDel(); return false" /></a>--%>
                &nbsp;&nbsp;<asp:ImageButton ID="SaveBtn" runat="server" ImageUrl="Icons/save.jpg" Style="height: 21px" />
                &nbsp;
            </div>
        </div>
        <div>
            <div id="div1" runat="server" style="float: left; width: 40%; border: solid; border-color: gray; border-width: 1px; margin-right: 10px; margin-top: 10px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; height: 92px;">

                <div style="padding-bottom: 5px;"><strong>&nbsp;FundCenter</strong></div>


                <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1" Height="30px" Width="100%" EnableTheming="True">
                    <asp:TabPanel ID="TabPanel1" runat="server" HeaderText="ตั้งแต่ ถึง">
                        <ContentTemplate>
                            <table>
                                <tr>
                                    <td>ตั้งแต่</td>
                                    <td>
                                        <ISWebCombo:WebCombo ID="WebCombo1" Width="200px" runat="server" UseDefaultStyle="True" DataTextField="Description" DataValueField="FundCenterCode" Height="20px" AdditionalSearchFields="FundCenterCode" AllowWildCardSearch="true">
                                            <LayoutSettings AlwaysShowAllRowsOnDropdown="true" AlwaysShowHelpButton="false" ComboMode="MultipleColumns">
                                            </LayoutSettings>
                                            <Columns>
                                                <ISWebCombo:WebComboColumn BaseFieldName="Description" Name="Description" HeaderText="ชื่อ FundCenter" Width="250px" />
                                                <ISWebCombo:WebComboColumn BaseFieldName="FundCenterCode" Name="FundCenterCode" HeaderText="รหัส FundCenter" Width="80px" />
                                            </Columns>
                                        </ISWebCombo:WebCombo>
                                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataByUser" TypeName="BasicDataTableAdapters.FCTR_Child2TableAdapter">
                                            <SelectParameters>
                                                <asp:SessionParameter Name="username" SessionField="users" Type="String" />
                                            </SelectParameters>
                                        </asp:ObjectDataSource>
                                    </td>
                                    <td>ถึง</td>
                                    <td>
                                        <ISWebCombo:WebCombo ID="WebCombo2" Width="200px" runat="server" UseDefaultStyle="True" DataTextField="Description" DataValueField="FundCenterCode" Height="20px" AdditionalSearchFields="FundCenterCode" AllowWildCardSearch="true">
                                            <LayoutSettings AlwaysShowAllRowsOnDropdown="true" AlwaysShowHelpButton="false" ComboMode="MultipleColumns">
                                            </LayoutSettings>
                                            <Columns>
                                                <ISWebCombo:WebComboColumn BaseFieldName="Description" Name="Description" HeaderText="ชื่อ FundCenter" Width="250px" />
                                                <ISWebCombo:WebComboColumn BaseFieldName="FundCenterCode" Name="FundCenterCode" HeaderText="รหัส FundCenter" Width="80px" />
                                            </Columns>
                                        </ISWebCombo:WebCombo>
                                        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataByUser" TypeName="BasicDataTableAdapters.FCTR_Child2TableAdapter">
                                            <SelectParameters>
                                                <asp:SessionParameter Name="username" SessionField="users" Type="String" />
                                            </SelectParameters>
                                        </asp:ObjectDataSource>
                                    </td>
                                </tr>
                            </table>

                        </ContentTemplate>
                    </asp:TabPanel>
                    <asp:TabPanel ID="TabPanel2" runat="server" HeaderText="เลือกเอง">
                        <ContentTemplate>
                            <div style="margin-left: 30px; color: gray; font-size: 11px;">
                                <ISWebCombo:WebCombo ID="WebCombo3" runat="server" UseDefaultStyle="True" Width="350px" DataTextField="pathname" DataValueField="Fundcenter_FundcenterCode" AllowWildCardSearch="true" DropDownRows="100000">
                                    <LayoutSettings AlwaysShowAllRowsOnDropdown="true" AlwaysShowHelpButton="false">
                                    </LayoutSettings>                                    
                                </ISWebCombo:WebCombo>
                                &nbsp;(รวมหน่วยงานใต้สังกัด)
                            </div>
                        </ContentTemplate>
                    </asp:TabPanel>
                </asp:TabContainer>
            </div>
            <div id="div2" runat="server" style="float: right; width: 53%; border: solid; border-color: gray; border-width: 1px; margin-right: 30px; margin-top: 10px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; height: 92px;">
                &nbsp;
                <strong>
                    <asp:Label runat="server" ID="programs"></asp:Label></strong>
                <div style="margin: 5px 5px 5px 5px;">
                    <asp:HiddenField runat="server" ID="hdf1" />
                    <asp:ListBox ID="ms8" runat="server" Width="97%" SelectionMode="Multiple"></asp:ListBox><br />
                </div>

            </div>
            <div id="div3" runat="server" style="float: left; width: 40%; border: solid; border-color: gray; border-width: 1px; margin-right: 30px; margin-top: 10px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; height: 92px;">
                &nbsp;
                <strong>Commitment Item</strong>
                <div style="margin: 5px 5px 5px 5px;">
                    <asp:HiddenField runat="server" ID="hdf3" />
                    <asp:ListBox ID="ListBox1" runat="server" Width="97%" SelectionMode="Multiple"></asp:ListBox><br />
                </div>

            </div>
            <div id="div4" runat="server" style="float: right; width: 53%; border: solid; border-color: gray; border-width: 1px; margin-right: 30px; margin-top: 10px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; height: 92px;">
                &nbsp;
                <strong>กิจกรรม</strong>
                <div style="margin: 5px 5px 5px 5px;">
                    <asp:HiddenField runat="server" ID="hdf2" />
                    <asp:ListBox ID="ListBox2" runat="server" Width="97%" SelectionMode="Multiple"></asp:ListBox><br />
                </div>

            </div>
            <script type="text/javascript">
                $(document).ready(function () {
                    

                    var ms10 = $('#<%= ListBox1.ClientID%>').magicSuggest({
                        // will fetch data from options
                    });
                    
                    var ms7 = $('#<%= ms8.ClientID%>').magicSuggest({
                        // will fetch data from options
                    });
                    var ms9 = $('#<%= ListBox2.ClientID%>').magicSuggest({
                        // will fetch data from options
                    });
                    clickedx = function () {
                        //alert('qq');
                        $("#<%= hdf1.ClientID%>").val(ms7.getValue());
                        $("#<%= hdf3.ClientID%>").val(ms10.getValue());
                        $("#<%= hdf2.ClientID%>").val(ms9.getValue());
                        TINY.box.show({ iframe: 'loading.html', boxid: 'frameless', close: 0, width: 300, height: 260, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { } });
                        //alert('dd');
                        return false;
                    }
                });
                function clickedx1() {
                    alert('ee');
                    TINY.box.show({ iframe: 'loading.html', boxid: 'frameless', close: 0, width: 300, height: 260, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { } });
                    return false;
                }
            </script>
            <div style="float: left; width: 97%; border: solid; border-color: gray; border-width: 1px; margin-top: 10px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; padding: 5px 5px 5px 5px;">

                <div style="padding-bottom: 5px;"><strong>การกระจายรายเดือน</strong></div>
                <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="Icons/krajai12.png" Style="height: 21px" OnClientClick="popupwaitForce()" />
                <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="Icons/krajai4.png" Style="height: 21px"  OnClientClick="popupwaitForce()"/>
                <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="Icons/krajaiselect.png" Style="height: 21px" />
                <asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="Icons/krajaibudget.png" Style="height: 21px" Visible="false" />
                <asp:ImageButton ID="ImageButton5" runat="server" ImageUrl="Icons/krajaicash.png" Style="height: 21px" Visible="false" />
                <br />
                <ISWebGrid:WebGrid ID="WebGrid1" runat="server" UseDefaultStyle="True" Width="100%" OnUpdateRow="WebGrid1_UpdateRow" DefaultStyleMode="Silver" OnInitializePostBack="WebGrid1_InitializePostBack" Height="350px" OnInitializeRow="WebGrid1_InitializeRow">
                    <LayoutSettings AllowAddNew="No" EditOnClick="True" AllowColumnMove="No"
                        AllowEdit="Yes" AllowDelete="Yes" AllowSorting="Yes" ColumnFooters="Yes" NewRowLostFocusAction="AlwaysUpdate"
                        ResetNewRowValuesOnError="False" InProgressUIBehavior="ChangeCursorToHourGlass"
                        AlwaysShowHelpButton="false" ColumnFooterAggregateMode="CalculateAllData"
                        VirtualLoadMode="Default" AllowGrouping="Yes">
                        <RowStyle Font-Names="Tahoma" Font-Size="9" CustomRules="overflow: hidden;" />
                        <AlternatingRowStyle Font-Names="Tahoma" Font-Size="9" BackColor="#fbfbfb" CustomRules="overflow: hidden;" />
                        <ClientSideEvents OnRowValidate="WebGrid1_OnRowValidate" OnRowContextMenu="WebGrid1_OnRowContextMenu" OnRowSelect="OnRowSelect" OnAfterExitEditMode="WebGrid1_OnAfterExitEditMode" OnEditKeyDown="WebGrid1_OnEditKeyDown" OnAfterResponseProcess="DisableCheck" />
                    </LayoutSettings>
                    <RootTable DataKeyField="Id">
                        <Columns>
                            <ISWebGrid:WebGridColumn IsRowChecker="true" Name="checker">
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Caption="Fund Center" Name="FundCenter" DataMember="FundCenter_FundCenterCode" Width="100px">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Left" />

                            </ISWebGrid:WebGridColumn>

                            <ISWebGrid:WebGridColumn Name="Project" Width="120px" Caption="โครงการ" DataMember="Project_ProjectCode">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Left" />

                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="cmmts" Width="120px" Caption="Commitment Item" DataMember="Cmmt_CmmtCode" DefaultValue="0" DefaultText="0">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Left" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="products" Width="120px" Caption="ผลิตภัณฑ์" DataMember="Product_ProductCode" DefaultValue="0" DefaultText="0">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Left" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="acttype" Width="120px" Caption="ครุภัณฑ์" DataMember="ActivityType_ActivityTypeCode">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Left" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="cmmtdet" Width="120px" Caption="รายการ" DataMember="Cmmtdetail_Id" DefaultValue="0" DefaultText="0">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Left" />
                            </ISWebGrid:WebGridColumn>

                            <ISWebGrid:WebGridColumn Name="acti" Width="120px" Caption="กิจกรรม" DataMember="Activity_ActivityCode" DefaultValue="0" DefaultText="0" FooterText="รวมทั้งหมด">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Left" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="sumamount" Width="120px" Caption="รวม" DataMember="Amount" DataFormatString="##,##0" DefaultValue="0" DefaultText="0" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="janblank" Width="80px" Caption="ม.ค." DataMember="Amount1" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="febblank" Width="80px" Caption="ก.พ." DataMember="Amount2" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="marblank" Width="80px" Caption="มี.ค." DataMember="Amount3" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="aprblank" Width="80px" Caption="เม.ย." DataMember="Amount4" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="mayblank" Width="80px" Caption="พ.ค." DataMember="Amount5" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="junblank" Width="80px" Caption="มิ.ย." DataMember="Amount6" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="julblank" Width="80px" Caption="ก.ค." DataMember="Amount7" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="augblank" Width="80px" Caption="ส.ค." DataMember="Amount8" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="sepblank" Width="80px" Caption="ก.ย." DataMember="Amount9" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="octblank" Width="80px" Caption="ต.ค." DataMember="Amount10" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="novblank" Width="80px" Caption="พ.ย." DataMember="Amount11" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="decblank" Width="80px" Caption="ธ.ค." DataMember="Amount12" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="last1year" Width="80px" Caption="Y+1" DataMember="ForecastYear1" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="last2year" Width="80px" Caption="Y+2" DataMember="ForecastYear2" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="last3year" Width="80px" Caption="Y+3" DataMember="ForecastYear3" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>
                            <ISWebGrid:WebGridColumn Name="last4year" Width="80px" Caption="Y+4" DataMember="ForecastYear4" DataFormatString="##,##0.00" DefaultValue="0.00" DefaultText="0.00" AggregateFunction="Sum">
                                <HeaderStyle HorizontalAlign="Center" />
                                <CellStyle HorizontalAlign="Right" />
                            </ISWebGrid:WebGridColumn>


                        </Columns>
                    </RootTable>
                    <CustomEditors>
                        <ISWebGrid:WebGridCustomEditor ControlType="DHTMLClientControl" JavascriptFiles="Calculator.js" Name="Calculator" Persistence="DesignerLevel" ScriptFolder="EditorsPack1">
                            <Behavior DropdownButtonImageFile="CalcDD.gif" HasDropdownButton="True" />
                        </ISWebGrid:WebGridCustomEditor>
                        <ISWebGrid:WebGridCustomEditor ControlType="DHTMLClientControl" JavascriptFiles="NumericUpDown.js" Name="NumericUpDown" Persistence="DesignerLevel" ScriptFolder="EditorsPack1">
                            <Behavior HasDropdownButton="True" />
                        </ISWebGrid:WebGridCustomEditor>
                        <ISWebGrid:WebGridCustomEditor JavascriptFiles="RichTextBox.js" Name="RichTextBox" Persistence="DesignerLevel" ScriptFolder="EditorsPack1" ServerControlFullName="Telerik.WebControls.RadEditor">
                            <Behavior BaseEditorType="Custom" DropdownButtonType="Custom" HasDropdownButton="True" />
                        </ISWebGrid:WebGridCustomEditor>
                        <ISWebGrid:WebGridCustomEditor JavascriptFiles="WebInputNET.js" Name="WebInputNET" Persistence="DesignerLevel" ScriptFolder="WebInput" ServerControlFullName="ISNet.WebUI.WebControls.WebInput">
                        </ISWebGrid:WebGridCustomEditor>
                        <ISWebGrid:WebGridCustomEditor ControlType="DHTMLClientControl" JavascriptFiles="SlideBar.js" Name="Slidebar" Persistence="DesignerLevel" ScriptFolder="EditorsPack2">
                            <Behavior DropdownButtonImageFile="SliderDD.gif" HasDropdownButton="True" />
                        </ISWebGrid:WebGridCustomEditor>
                        <ISWebGrid:WebGridCustomEditor ControlType="DHTMLClientControl" JavascriptFiles="HtmlEditor.js" Name="HtmlEditor" Persistence="DesignerLevel" ScriptFolder="EditorsPack2">
                            <Behavior BaseEditorType="Custom" />
                        </ISWebGrid:WebGridCustomEditor>
                        <ISWebGrid:WebGridCustomEditor ControlType="DHTMLClientControl" DependencyFiles="SmartWebResources\S\WebScheduler_Calendar.js\301000" JavascriptFiles="VistaCalendar.js;VistaCalendar.css" Name="VistaCalendar" Persistence="DesignerLevel" ScriptFolder="EditorsPack3">
                            <Behavior DropdownButtonImageFile="VistaCalendar.gif" HasDropdownButton="True" SupportElegantStyles="True" />
                        </ISWebGrid:WebGridCustomEditor>
                        <ISWebGrid:WebGridCustomEditor JavascriptFiles="WebTextEditor.js" Name="WebTextEditor" Persistence="DesignerLevel" ScriptFolder="EditorsPack3" ServerControlFullName="ISNet.WebUI.WebTextEditor.WebTextEditor">
                            <Behavior BaseEditorType="Custom" />
                        </ISWebGrid:WebGridCustomEditor>
                    </CustomEditors>
                </ISWebGrid:WebGrid>


            </div>
        </div>
    </div>
    <br />
    <br />
    <ISWebTreeView:WebTreeView ID="WebTreeView1" runat="server" Height="265px" Width="235px" Visible="false">
        <NodeSettings EnableAnimation="True" />
    </ISWebTreeView:WebTreeView>
    <ISWebTreeView:WebTreeView ID="WebTreeView2" runat="server" Height="265px" Width="235px" Visible="false">
        <NodeSettings EnableAnimation="True" />
    </ISWebTreeView:WebTreeView>
    <ISWebTreeView:WebTreeView ID="WebTreeView3" runat="server" Height="265px" Width="235px" Visible="false">
        <NodeSettings EnableAnimation="True" />

    </ISWebTreeView:WebTreeView>

    <script>
        function WebGrid_GetTotalRowCount() {

            try {

                var grid = ISGetObject("WebGrid1")
                if (grid == null || grid.RootTable == null) { alert(grid); return 0; }

                // NOTE: This is done because Intersoft doesn't return the TotalRows accurately for a WebGrid using BatchUpdate
                var rowCount = 0;
                while (true) {
                    var row = grid.RootTable.GetRow(rowCount)
                    if (row == null) { return rowCount; }
                    rowCount++;
                }
                //alert(rowCount);
            }
            catch (ex) {
                ShowJSException(ex);

            }
        }

        function DisableCheck() {
            try {
                var rowcount = WebGrid_GetTotalRowCount();
                var WebGrid1 = ISGetObject("WebGrid1");
                var rowCheckerElm = WebGrid1.RootTable.GetElement(WG40.COLHEADER, WG40.HTMLTABLE).cells[1].childNodes[0].childNodes[0].childNodes[0];

                if (rowcount == 0) {
                    rowCheckerElm.checked = false;
                    rowCheckerElm.disabled = true;


                    return true;
                } else {
                    rowCheckerElm.disabled = false;

                }
            } catch (err) { }
        }
        DisableCheck();
    </script>

    <%= ScriptText %>
</asp:Content>
